package com.sdgakj.interviews.job20180816;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;

public class Alith {

	public static void main(String[] args) {
		// 1. 用1、2、3、4、5这五个数字，用java写一个main函数，打印出所有不同的排列，如：51234、41235等

		getStr(5);
	}

	private static void getStr(int num) {
		if (num <= 0) {
			System.out.println("");
		}
		List<Integer> list = new ArrayList<>();

		for (int i = 1; i <= num; i++) {
			list.add(i);
		}
		System.out.println(JSONObject.toJSONString(list));
		System.out.println("==========================");

		for (int i = 1; i < num; i++) {
			
			StringBuilder sb = new StringBuilder();
			List<Integer> tempList = new ArrayList<>();
			tempList.addAll(list);
			System.out.println(JSONObject.toJSONString("TEMPLIST FIRST === " + tempList));
			sb.append(i);
			tempList.remove(i);
			System.out.println(JSONObject.toJSONString("TEMPLIST === " + tempList));
			System.out.println(JSONObject.toJSONString("LIST === " + list));
			System.out.println("==========================");
			for(Integer m : tempList){
				sb.append(m);
			}
			System.out.println(sb);
		}
	}
}
